Add support for Sourcify contract information lookup#1899
Add support for Sourcify contract information lookup#1899YaroShkvorets merged 9 commits intographprotocol:mainfrom
Conversation
🦋 Changeset detectedLatest commit: dfd7bde The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
6464dbd to
e9206b6
Compare
- Contract name, ABI and creation transaction hash (start block) from [Sourcify API](https://docs.sourcify.dev/docs/api/). - Runs before the registry lookup and replaces default values (not interactive) if not provided by the user. This means priority for CLI parameters looks like: user submitted (env/CLI args) > Sourcify API > Default values > Registry fetch
e9206b6 to
c5c9010
Compare
5d4312f to
19cbd8a
Compare
There was a problem hiding this comment.
Looks good.
Can we add a couple of test cases to https://github.com/graphprotocol/graph-tooling/blob/main/packages/cli/src/command-helpers/contracts.test.ts
Also, any idea why it can't find source code on Sourcify for this contract on mainnet: 0xb47e3cd837dDF8e4c57F05d70Ab865de6e193BBB. It exists on Etherscan. I thought it's supposed to import it from etherscan?
25fd23e to
7aa683f
Compare
YaroShkvorets
left a comment
There was a problem hiding this comment.
LGTM
added some retry logic to etherscan tests to handle rate-limited endpoints
* Add support for Sourcify contract information lookup - Contract name, ABI and creation transaction hash (start block) from [Sourcify API](https://docs.sourcify.dev/docs/api/). - Runs before the registry lookup and replaces default values (not interactive) if not provided by the user. This means priority for CLI parameters looks like: user submitted (env/CLI args) > Sourcify API > Default values > Registry fetch * Fix incorrect ABI instantiation for `init` with parameters * Add changeset * Throw early for non-EVM chains * Add tests for contract name and startBlock info * Add test for non-evm contract lookup * removed hardcoded wax check, added test * add retries to tests --------- Co-authored-by: YaroShkvorets <shkvorets@gmail.com>
Etherscan requires an API key for ABI lookup and other operations.
Sourcify (https://sourcify.dev/) is an open-source decentralized alternative.
Features
This means priority for CLI parameters looks like:
user submitted (env/CLI args) > Sourcify API > Default values > Registry fetch
Closes #1001.
Details
The
getFromSourcifymethod returns all the information related to contracts that are normally fetch from registry URLs:It internally makes the RPC call for the
startBlockusing the creation transaction hash.